package cn.kgc.springday01.service.impl;

import cn.kgc.springday01.annotations.AutoWired;
import cn.kgc.springday01.dao.UserDao;
import cn.kgc.springday01.service.UserService;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/6/10
 * @Description:
 *
 * new  方式创建对象   存在耦合    不利于代码的维护
 * 开闭原则
 */
public class UserServiceImpl implements UserService {

    //private UserDao userDao = new UserDaoImpl();
    //private UserDao userDao = new NewUserDaoImpl();
    //private UserDao userDao = BeanFactory.getUserDao();
    //private UserDao userDao = BeanFactory.getBean(UserDaoImpl.class);

    // 通过配置文件的方式获取实例对象
    //private  UserDao userDao = BeanFactory.getBean("userDao",UserDao.class);

    @AutoWired
    private  UserDao userDao ;

    @Override
    public void add() {
        userDao.add();
    }
}
